﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace Tradex.Messages {
    
    /// <summary>
    /// A Pong message is the answer to a Ping message.
    /// </summary>
    [Serializable()]
    public sealed class PongMessage : Message {

        /// <summary>
        /// Constructor creating an anser from the querying Ping.
        /// </summary>
        /// <param name="ping"></param>
        public PongMessage(PingMessage ping) {
            if (ping == null) {
                throw new ArgumentException("value can not be null", "ping");
            }
            Contract.EndContractBlock();

            Identity = ping.Identity;
            Timestamp = ping.Timestamp;
        }

        /// <inheritdoc />
        public override MessageCode Code {
            get { return MessageCode.Pong; }
        }

        /// <summary>
        /// The identity of the request.
        /// </summary>
        public Guid Identity { get; private set; }

        /// <summary>
        /// The timestamp of the request.
        /// </summary>
        public DateTime Timestamp { get; private set; }

    }
}
